<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<%@ include file="../../common_header.jsp"%>
<script type="text/javascript">
	//所有的子窗体都需要有一个save函数，当点击弹出窗体的保存按钮时所进行的操作

	function btnSave_click() {
			var fun_ret;
			var file = $('#uploadFile')[0];
			var imagSize =  document.getElementById("uploadFile").files[0];
			if(imagSize != null && imagSize != "" && !isNull( imagSize )){
				
				imagSize = imagSize.size;
			}
			name = file.value;
			var pic = /.+(.JPEG|.jpeg|.JPG|.jpg|.GIF|.gif|.BMP|.bmp|.PNG|.png)$/;
			var end = name.substr(name.lastIndexOf("."));
			//var end = name.substr(name.length - 4);
			//if(!pic.test(end)){
			if (name != "" && name != null && end !=".jpg" && end !=".JPEG" && end !=".jpeg" &&end !=".JPG" && end !=".PNG" && end !=".png" ) {
				$.messager.alert("提示", " 您选择的不是图片文件，请重新选择！");
				return false;
			}else{
				if(imagSize > 204800){
						$.messager.alert("错误提示", "图片需要限制在200kb以内！");
				        return false;
				}
			}
			var formData = new FormData($('#formModule')[0]);
			
			$.ajax(
					{
						url : '${saveUrl}', //server script to process data
						type : 'POST',
						data : formData,
						async: false,
						cache : false,
						contentType : false,
						processData : false,
						dataType:'json',//请求的数据类型
						xhr : function() { // custom xhr
							myXhr = $.ajaxSettings.xhr();
							if (myXhr.upload) { // if upload property exists
								myXhr.upload.addEventListener('progress',
										progressHandlingFunction, false); // progressbar
							}
							return myXhr;

						},
						//Ajax events
						success : function(data) {
				               if(data.success == 0 )
				               {
				            	   fun_ret = true;
				                  
				               }
				               else
				               {
				            	   top.Ext.Msg.alert("返回提示",data.msg);
				               }
				           },
						error : errorHandler = function(data) {
							$.messager.alert("错误提示", data.msg);
							return false;
						}
					});	
			
	return fun_ret;
	}
	
	function progressHandlingFunction(e) {
		if (e.lengthComputable) {
			$('progress').attr({
				value : e.loaded,
				max : e.total
			});
		}
	}
	
	 $(document).ready(function(){
		//获取当前用户可查看到的部门
		showDataInCombotree('${ctx }/manage/sysDepartment/getAllDepaetment?flag=0',$("#depId"),'${model.depPId}');
	  });
	
</script>
</head>
<body>
	<div style="padding: 1px" align="center">
	
		<form id="formModule" method="post">
			<input id="id" type="hidden" name="depId" value="${model.depId }">
            <input id="icon" type="hidden" name="icon" value="${model.icon }">
            <table border="0" cellpadding="5">
                <tr>
                    <td height="28">上级单位：</td>
                    <td><select id="depId" name="depPId" class="easyui-combotree" style="width:232px;height:23px" data-options="required:true,editable:false">
						</select>
					</td>
                </tr>
                <tr>
                    <td height="28">单位名称：</td>
                    <td><input id="depName" class="easyui-validatebox textbox" type="text" name="depName" data-options="required:true" style="width:230px;height:20px;" value="${model.depName }"></input></td>
                </tr>
               <!--   <tr>
                    <td height="28">负责人：</td>
                    <td><input id="leader" class="easyui-combobox" name="leader" data-options="valueField:'id',textField:'text'" style="width:232px;height:23px;"></td>
                </tr>-->
                <tr>
                    <td height="28">单位地址：</td>
                    <td><input id="address" class="easyui-validatebox textbox" type="text" name="address" maxlength="280" data-options="" style="width:230px;height:20px;" value="${model.address }"></input></td>
                </tr>
                <tr>
                    <td height="28">单位电话：</td>
                    <td><input id="phone" class="easyui-validatebox textbox" onkeyup="value=value.replace(/[^1234567890-]+/g,'')" type="text" name="phone" maxlength="100" style="width:230px;height:20px;" value="${model.phone }"></input></td>
                </tr>
				 <tr>
                    <td height="28">校徽：</td>
                    <td><input type="file" class="easyui-linkbutton"
						data-options="toggle:true,group:'g2',plain:true"
						accept="image/*" id="uploadFile"
						name="uploadFile" style="width: 200px;" /></td>
                </tr>	
                <tr>
                    <td height="28">单位说明：</td>
                    <td><textarea id="desction" rows="4" cols="36" style="width:230px;" name="desction">${model.desction }</textarea></td>
                </tr>
                <tr>
                    <td height="28">单位类型：</td>
                   <td><select id="status" name="depType" style="width:102px;height:23px;">
                            <option value="1" <c:if test="${model.depType==1}">selected</c:if>>学校</option>
                            <option value="2" <c:if test="${model.depType==2}">selected</c:if>>商家</option>
                            <option value="3" <c:if test="${model.depType==3}">selected</c:if>>其他</option>
                        </select></td>
                </tr>
                <tr>
                    <td height="28" >状态：</td>
                    <td><select id="status" name="status" style="width:102px;height:23px;">
                            <option value="9" <c:if test="${model.status==9}">selected</c:if>>启用</option>
                            <option value="1" <c:if test="${model.status==0}">selected</c:if>>移除</option>
                        </select></td>
                </tr>
            </table>
		</form>
	</div>
</body>
</html>
